<?php

namespace frontend\models;

use Yii;

/**
 * This is the model class for table "details".
 *
 * @property integer $id
 * @property integer $user_id
 * @property string $name
 * @property string $areas
 * @property integer $sex
 * @property string $introduce
 * @property integer $age
 * @property integer $phone
 */
class User_details extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'details';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_id', 'sex', 'age', 'phone'], 'integer'],
            [['name'], 'string', 'max' => 60],
            [['areas', 'introduce'], 'string', 'max' => 100]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'user_id' => 'User ID',
            'name' => 'Name',
            'areas' => 'Areas',
            'sex' => 'Sex',
            'introduce' => 'Introduce',
            'age' => 'Age',
            'phone' => 'Phone',
        ];
    }

    /**
     * @修改用户信息
     */
    public function update_User($data,$user_id)
    {
        $user = $this->find()->where(['user_id'=>$user_id])->one();

        $user->name = $data['name'];
        $user->age = $data['age'];
        $user->sex = $data['sex'];
        $user->areas = $data['areas'];
        $user->introduce = $data['introduce'];
        $user->phone = $data['phone'];
        return $user->save();
    }

}
